# justfile

# Default task
default: release

# Update version, build, and package
release:
    @just update-version
    @just build
    @just package
    @just upload

# Update version (cross-platform)
update-version:
    @echo "Bumping version..."
    @python -c "with open('version.txt', 'r+') as f: v = int(f.read().strip()) + 1; f.seek(0); f.truncate(); f.write(str(v))"

# Build the application (cross-platform)
build:
    pyinstaller --noconfirm --onefile --windowed "main.py"

# Package the application
[os="windows"]
package:
    @powershell -Command "$version = Get-Content version.txt; Compress-Archive -Path 'dist/main.exe' -DestinationPath \"dist/main-$version.zip\" -Force"

[os="macos"]
[os="linux"]
package:
    @bash -c 'version=$(cat version.txt); zip -r "dist/main-$version.zip" "dist/main.app"'

# Upload the packaged file (placeholder)
[os="windows"]
upload:
    @powershell -Command "$version = Get-Content version.txt; echo \"Uploading dist/main-$version.zip...\""

[os="macos"]
[os="linux"]
upload:
    @bash -c 'version=$(cat version.txt); echo "Uploading dist/main-$version.zip..."'

# Clean up build artifacts
[os="windows"]
clean:
    @echo "Cleaning up..."
    @if exist build (rd /s /q build)
    @if exist dist (rd /s /q dist)
    @if exist *.spec (del /q *.spec)

[os="macos"]
[os="linux"]
clean:
    @echo "Cleaning up..."
    @rm -rf build dist *.spec